﻿/********************************************************************
FileName    :   Bll_OS.cs
CreateTime  :   2020-09-19 03:07:30
BaseClass   :   Bll_OS
FileType    :   .cs
Author      :  minjie
Description :   Bll_OS层（简单三层）
*********************************************************************/

using System;
using System.Text;
using System.Collections.Generic;

using System.Data;
using OS.DAL;
namespace OS.BLL
{
    /// <summary>
    /// Bll_sys_DICTIONARY的摘要说明。
    /// </summary>
    public partial class Bll_jbxx_spdaH
    {

        private readonly Dal_jbxx_spdaH dal = new Dal_jbxx_spdaH();
        public Bll_jbxx_spdaH()
        { }

        #region  Method 

        public bool Exists(int DjLsh)
        {
            return dal.Exists(DjLsh);
        }

        /// <summary> 
        /// 增加一条数据 
        /// </summary> 
        public bool Add(jbxx_spdaH_Entity model)
        {
            return dal.Add(model);
        }

        /// <summary> 
        /// 增加一条数据 
        /// </summary> 
        public string AddStr(jbxx_spdaH_Entity model)
        {
            return dal.AddStr(model);
        }

        /// <summary> 
        /// 更新一条数据 
        /// </summary> 
        public bool Update(jbxx_spdaH_Entity model)
        {
            return dal.Update(model);
        }

        /// <summary> 
        /// 更新一条数据(字符串) 
        /// </summary> 
        public string UpdateStr(jbxx_spdaH_Entity model)
        {
            return dal.UpdateStr(model);
        }

        /// <summary> 
        /// 删除一条数据 
        /// </summary> 
        public bool Delete(int DjLsh)
        {

            return dal.Delete(DjLsh);
        }
        /// <summary> 
        /// 批量删除一批数据 
        /// </summary> 
        public bool DeleteList(string lists)
        {
            return dal.DeleteList(lists);
        }
        /// <summary> 
        /// 得到一个对象实体 
        /// </summary> 
        public jbxx_spdaH_Entity GetModel(int DjLsh)
        {
            return dal.GetModel(DjLsh);
        }
        public jbxx_spdaH_Entity GetModel(string spbh)
        {
            return dal.GetModel(spbh);
        }

        /// <summary> 
        /// 获得数据列表 
        /// </summary> 
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }


        /// <summary> 
        /// 获得数据列表 
        /// </summary> 
        public List<jbxx_spdaH_Entity> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary> 
        /// 获得数据列表 
        /// </summary> 
        public List<jbxx_spdaH_Entity> GetModelList(string strWhere, string orderby, int startIndex, int endIndex)
        {
            DataSet ds = dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary> 
        /// 获得数据列表 
        /// </summary> 
        public List<jbxx_spdaH_Entity> DataTableToList(DataTable dt)
        {
            List<jbxx_spdaH_Entity> modelList = new List<jbxx_spdaH_Entity>();
            if (dt != null)
            {
                int rowsCount = dt.Rows.Count;
                if (rowsCount > 0)
                {
                    jbxx_spdaH_Entity model;
                    for (int n = 0; n < rowsCount; n++)
                    {
                        model = new jbxx_spdaH_Entity();

                        if (dt.Rows[n]["DjLsh"] != null && dt.Rows[n]["DjLsh"].ToString() != "")
                            model.DjLsh = int.Parse(dt.Rows[n]["DjLsh"].ToString());


                        if (dt.Rows[n]["DjBtZdh"] != null && dt.Rows[n]["DjBtZdh"].ToString() != "")
                            model.DjBtZdh = int.Parse(dt.Rows[n]["DjBtZdh"].ToString());


                        if (dt.Rows[n]["DjFtZdh"] != null && dt.Rows[n]["DjFtZdh"].ToString() != "")
                            model.DjFtZdh = int.Parse(dt.Rows[n]["DjFtZdh"].ToString());


                        if (dt.Rows[n]["DjStZdh"] != null && dt.Rows[n]["DjStZdh"].ToString() != "")
                            model.DjStZdh = int.Parse(dt.Rows[n]["DjStZdh"].ToString());

                        model.DjState = dt.Rows[n]["DjState"].ToString();

                        if (dt.Rows[n]["DjCount"] != null && dt.Rows[n]["DjCount"].ToString() != "")
                            model.DjCount = int.Parse(dt.Rows[n]["DjCount"].ToString());

                        model.spmc = dt.Rows[n]["spmc"].ToString();
                        model.tmh = dt.Rows[n]["tmh"].ToString();
                        model.cjhh = dt.Rows[n]["cjhh"].ToString();
                        model.xlmc = dt.Rows[n]["xlmc"].ToString();
                        model.xlbh = dt.Rows[n]["xlbh"].ToString();
                        model.gg = dt.Rows[n]["gg"].ToString();
                        model.dw = dt.Rows[n]["dw"].ToString();
                        if (dt.Rows[n]["jj"] != null && dt.Rows[n]["jj"].ToString() != "")
                            model.jj = decimal.Parse(dt.Rows[n]["jj"].ToString());

                        if (dt.Rows[n]["lsj"] != null && dt.Rows[n]["lsj"].ToString() != "")
                            model.lsj = decimal.Parse(dt.Rows[n]["lsj"].ToString());

                        if (dt.Rows[n]["pfj"] != null && dt.Rows[n]["pfj"].ToString() != "")
                            model.pfj = decimal.Parse(dt.Rows[n]["pfj"].ToString());

                        model.sfty = dt.Rows[n]["sfty"].ToString();
                        model.ys = dt.Rows[n]["ys"].ToString();
                        if (dt.Rows[n]["kcsj"] != null && dt.Rows[n]["kcsj"].ToString() != "")
                            model.kcsj = decimal.Parse(dt.Rows[n]["kcsj"].ToString());

                        if (dt.Rows[n]["kcxx"] != null && dt.Rows[n]["kcxx"].ToString() != "")
                            model.kcxx = decimal.Parse(dt.Rows[n]["kcxx"].ToString());

                        //   model.tp = dt.Rows[n]["tp"].ToString();
                        model.bhfs = dt.Rows[n]["bhfs"].ToString();
                        model.splm = dt.Rows[n]["splm"].ToString();
                        model.spbh = dt.Rows[n]["spbh"].ToString();
                        model.gysbh = dt.Rows[n]["gysbh"].ToString();
                        model.gysmc = dt.Rows[n]["gysmc"].ToString();
                        if (dt.Rows[n]["gyszk"] != null && dt.Rows[n]["gyszk"].ToString() != "")
                            model.gyszk = decimal.Parse(dt.Rows[n]["gyszk"].ToString());

                        model.flh = dt.Rows[n]["flh"].ToString();
                        model.flmc = dt.Rows[n]["flmc"].ToString();
                        model.ysbh = dt.Rows[n]["ysbh"].ToString();
                        model.spjm = dt.Rows[n]["spjm"].ToString();
                        if (dt.Rows[n]["byj"] != null && dt.Rows[n]["byj"].ToString() != "")
                            model.byj = decimal.Parse(dt.Rows[n]["byj"].ToString());

                        model.bz = dt.Rows[n]["bz"].ToString();
                        model.djyh = dt.Rows[n]["djyh"].ToString();
                        if (dt.Rows[n]["djsj"] != null && dt.Rows[n]["djsj"].ToString() != "")
                            model.djsj = DateTime.Parse(dt.Rows[n]["djsj"].ToString());

                        model.xgyh = dt.Rows[n]["xgyh"].ToString();
                        if (dt.Rows[n]["xgsj"] != null && dt.Rows[n]["xgsj"].ToString() != "")
                            model.xgsj = DateTime.Parse(dt.Rows[n]["xgsj"].ToString());

                        model.zdbm = dt.Rows[n]["zdbm"].ToString();
                        model.zdtmh = dt.Rows[n]["zdtmh"].ToString();
                        model.zdzdbm = dt.Rows[n]["zdzdbm"].ToString();
                        model.sfdz = dt.Rows[n]["sfdz"].ToString();
                        model.bmbh = dt.Rows[n]["bmbh"].ToString();
                        model.bmmc = dt.Rows[n]["bmmc"].ToString();
                        model.dlbh = dt.Rows[n]["dlbh"].ToString();

                        //if (dt.Rows[n]["tp"] != null && dt.Rows[n]["tp"].ToString() != "")
                        //{
                        //    model.tp = (byte[])dt.Rows[n]["tp"];
                        //}
                 model.tpdz= dt.Rows[n]["tpdz"].ToString();
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary> 
        /// 获得数据列表 
        /// </summary> 
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary> 
        /// 批量处理 
        /// </summary> 
        public int ExecuteSqlTran(List<string> ls, ref string error)
        {
            return dal.ExecuteSqlTran(ls, ref error);
        }

        /// <summary> 
        /// 直接执行sql语句 
        /// </summary> 
        public int ExecuteSql(string sql)
        {
            return dal.ExecuteSql(sql);
        }

        /// <summary> 
        /// 直接执行sql语句 
        /// </summary> 
        public string GetSingle(string sql)
        {
            return dal.GetSingle(sql);
        }

        /// <summary> 
        /// 直接执行sql语句 
        /// </summary> 
        public DataTable ExecuteDt(string sql)
        {
            return dal.ExecuteDt(sql);
        }

        /// <summary> 
        /// 获取记录总数 
        /// </summary> 
        public int GetRecordCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }
        #endregion

    }

}
